package com.yz.aiks.multimodules.web.controller;

import com.yz.aiks.multimodules.JedisUtils;
import com.yz.base.boot.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * redis功能测试.
 *
 * @author <a href="mailto:aiks_yuan@163.com">yuanz</a>
 * @date 2022-02-24 15:27
 * @since 1.0.0
 **/
@RestController
@RequestMapping("/redis")
public class JedisTestController {
    
    @Autowired
    private JedisUtils jedisUtils;
    
    /**
     * 设置key.
     *
     * @param key
     * @param value
     * @return
     */
    @PostMapping("/setkey")
    public CommonResult<String> setKey(String key, String value) {
        String s = jedisUtils.exSet(key, value, 60);
        return CommonResult.ok(s);
    }
    
    /**
     * 获取key.
     *
     * @param key
     * @return
     */
    @PostMapping("/getkey")
    public CommonResult<String> getKey(String key) {
        String value = jedisUtils.get(key);
        return CommonResult.ok(value);
    }
}
